<!DOCTYPE html>
<html lang="en">
<head>
    <title>SSE with Spring Boot</title>
</head>
<body>
<h1>Receiving Server-Sent Events</h1>
<div id="messages"></div>
<script>
    let eventSource = new EventSource('http://localhost:8080/sse/demo/streamSseMvc');
    eventSource.onmessage = function (event) {
        let messages = document.getElementById('messages');
        let message = document.createElement('div');
        message.textContent = 'Message from server: ' + event.data;
        messages.appendChild(message);
    };
    eventSource.onerror = function (event) {
        console.error('EventSource failed:', event);
        eventSource.close();
    };
</script>
</body>
</html>
